package com.lagou.rpc.client;

import com.lagou.rpc.client.protocol.RpcInvoker;
import com.lagou.rpc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
public class ConsumerApplicaiton {
    public static void main(String[] args) {
        SpringApplication.run(ConsumerApplicaiton.class, args);
    }

    @RestController
    class TestController {

        @Autowired
        RpcInvoker invoker;
        TestController() {
        }

        @RequestMapping("/user")
        public String user() throws Exception {
            UserService userService = invoker.createProxy(UserService.class);
            return userService.say("hello");
        }
    }
}
